import { createStore, combineReducers, applyMiddleware, compose } from 'redux';
// 使得dispatch能够接收函数
import thunk from 'redux-thunk';
import reducers from './reducers';

const state = {
    //车次
    trainNumber: null,
    //出发车站
    departStation: null,
    //到达车站
    arriveStation: null,
    //座次类型
    seatType: null,
    //出发日期
    departDate: Date.now(),
    //到达日期
    arriveDate: Date.now(),
    //出发时间
    departTimeStr: null,
    //到达时间
    arriveTimeStr: null,
    //耗时
    durationStr: null,
    //价格
    price: null,
    //乘客数
    passengers: [],
    //菜单
    menu: null,
    //菜单显示
    isMenuVisible: false,
    //数据解析完成
    searchParsed: false,
};

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(
    combineReducers(reducers),
    state,
    composeEnhancers(applyMiddleware(thunk))
);
export default store;
